﻿package fpc.utils;

class Maths
{
	public static inline var INT_NULL = -0xfffff;
	
	public static inline function center(parent:Float, child:Float)
	{
		return Std.int(parent - child) >> 1;
	}
	
	public static inline function intMin(x:Int, y:Int)
	{
		return x < y ? x : y;
	}
	
	public static inline function intMax(x:Int, y:Int)
	{
		return x > y ? x : y;
	}
	
	/*public static function sortFloat(array:Array<Float>)
	{
		quicksort(array, 0, array.length - 1);
	}
	
	static function quicksort(tbuf:Array<Float>, lo:Int, hi:Int)
	{
		var i = lo;
		var j = hi;
		var p = tbuf[(lo + hi) >> 1];
		while ( i <= j )
		{
			while ( tbuf[i] > p )
			{
				i++;
			}
			while ( tbuf[j] < p )
			{
				j--;
			}
			if ( i <= j )
			{
				var t = tbuf[i];
				tbuf[i++] = tbuf[j];
				tbuf[j--] = t;
			}
		}
		if ( lo < j )
		{
			var hi = j;
			var i = lo;
			var p = tbuf[(lo + hi) >> 1];
			while ( i <= j )
			{
				while ( tbuf[i] > p )
				{
					i++;
				}
				while ( tbuf[j] < p )
				{
					j--;
				}
				if ( i <= j )
				{
					var t = tbuf[i];
					tbuf[i++] = tbuf[j];
					tbuf[j--] = t;
				}
			}
			if ( lo < j )
			{
				quicksort(tbuf, lo, j );
			}
			if ( i < hi )
			{
				quicksort(tbuf, i, hi );
			}
		}
		if ( i < hi )
		{
			var lo = i;
			var j = hi;
			var p = tbuf[(lo + hi) >> 1];
			while ( i <= j )
			{
				while ( tbuf[i] > p )
				{
					i++;
				}
				while ( tbuf[j] < p )
				{
					j--;
				}
				if ( i <= j )
				{
					var t = tbuf[i];
					tbuf[i++] = tbuf[j];
					tbuf[j--] = t;
				}
			}
			if ( lo < j )
			{
				quicksort(tbuf, lo, j );
			}
			if ( i < hi )
			{
				quicksort(tbuf, i, hi );
			}
		}
	}*/
}